package com.aaa.controller.scl;


import com.aaa.entity.LayData;
import com.aaa.entity.MyPage;
import com.aaa.entity.User;
import com.aaa.entity.scl.TsclPlan;
import com.aaa.entity.scl.TsclQuestion;
import com.aaa.service.scl.TsclPlanService;
import com.aaa.service.scl.TsclQuestionService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Date;

@Controller
@RequestMapping("tsclplan")
public class SClplanCountroller {

    @Resource
    private TsclPlanService tsclPlanService;


    /**
     * 查询计划
     */
    @ResponseBody
    @RequestMapping("sclplan")
    public LayData sclplan(MyPage myPage,TsclPlan tsclPlan){
        PageInfo pageInfo = tsclPlanService.selectAll(myPage, tsclPlan);
        LayData layData = new LayData(pageInfo);
        return layData;
    }

    /**
     *添加计划
     */
    @ResponseBody
    @PostMapping("addSCLplan")
    public LayData addSCLplan(TsclPlan tsclPlan){
        System.out.println("tsclPlan = " + tsclPlan);
        Boolean isno = tsclPlanService.insertPlan(tsclPlan);
        return new LayData(isno);
    }

    /**
     * 修改状态
     */
    @ResponseBody
    @PostMapping("updatas")
    public LayData updata(TsclPlan tsclPlan){
        Boolean isstatus=tsclPlanService.updatastatus(tsclPlan);
        LayData layData = new LayData(isstatus);
        return layData;
    }

    /**
     * 检测验证码是否存在
     */
    @PostMapping("checkCode")
    @ResponseBody
    public LayData checkcode(TsclPlan tsclPlan){
        Boolean isno = tsclPlanService.checkcode(tsclPlan);
        return new LayData(isno);
    }

    /**
     * 检测计划名称是否存在checkplanname
     */
    @PostMapping("checkplanname{planname}")
    @ResponseBody
    public LayData checkPlanName(@PathVariable String planname){
        Boolean isno = tsclPlanService.checkPlanname(planname);
        return new LayData(isno);
    }

}
